package com.gxc.event;

import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 事件监听器.
 *
 * @author 宫新程
 * @since 2019/1/25 11:03
 */
@Component
public class MyEventListener implements ApplicationListener<MyEvent> {

  @Async
  @Override
  public void onApplicationEvent(MyEvent myEvent) {
    Object source = myEvent.getSource();
    String simpleName = source.getClass().getName();
    System.out.println("simpleName：" + simpleName);

    for (int i = 0; i < 100; i++) {
      System.out.print(i);
    }

    String msg = myEvent.getMsg();
    System.out.println("msg：" + msg);
  }
}
